package com.rainng.coursesystem.controller.teacher;

import com.rainng.coursesystem.config.themis.annotation.Teacher;
import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.model.bo.HomeWorkDTO;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.HomeWorkService;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.*;

@Teacher
@RequestMapping("/teacher/homework")
@RestController("teacher_homeworkController")
public class HomeWorkController extends BaseController {
    private final HomeWorkService service;


    public HomeWorkController(HomeWorkService service) {
        this.service = service;
    }


    @ApiOperation(value = "新增作业")
    @PostMapping("create")
    public ResultVO addHomeWork(HomeWorkDTO dto){
        return service.addHomeWork(dto);
    }

    @ApiOperation("获取作业列表")
    @GetMapping("/getHomeworkList")
    public ResultVO getHomeWorkList(){
        return service.teacherGetHomeWorkList();
    }

    @PutMapping("/update/{homeworkId}")
    public ResultVO updateHomework(@PathVariable Integer homeworkId,HomeWorkDTO dto){
        return service.updateHomework(homeworkId,dto);
    }

    @DeleteMapping("/delete/{homeworkId}")
    public ResultVO deleteHomework(@PathVariable Integer homeworkId){
        return service.deleteHomework(homeworkId);
    }


    @PostMapping("/grade/{homeworkId}/{studentId}")
    public ResultVO gradeHomework(@PathVariable Integer homeworkId,@PathVariable Integer studentId,@RequestBody String grade){
        return service.gradeHomework(homeworkId,studentId,grade);
    }

}
